<!-- right-->

<div class="member-main">
    <div class="orderlist-warp">
        <div class="title"><{t}>我的结算单<{/t}></div>

    <div class="Plate">
         <h4>
             <{t}>状态：<{/t}> 
             <a  href="javascript:void(0);" args='all' search_type='type' onclick="tosearch(this)"><font <{if $type == 'nopayed'}>color="red"<{else}> color="#333"<{/if}>><{t}>全部<{/t}></font></a>
             <a  href="javascript:void(0);" args='ready'  search_type='type' onclick="tosearch(this)"><font <{if $type == 'ship'}>color="red"<{else}> color="#333"<{/if}>><{t}>待结算<{/t}></font></a>
             <a  href="javascript:void(0);" args='succ'  search_type='type' onclick="tosearch(this)"><font <{if $type == 'shiped'}>color="red"<{else}> color="#333"<{/if}>><{t}>已结算<{/t}></font></a>
            
         </h4>
         </div>
         <div class="clr"></div>
        <div >
            <form action="" method="post" id="frm">
            </form></div>
        <form action="<{link app=business ctl='site_member' act='save_balance'}>" method="post" >    
        <table class="gridlist table-goods-list" style="border-bottom:none" width="100%" border="0" cellspacing="0"  cellpadding="0">
        <{if !$msg}>
            <tr>
                <th class="first" ><input type='checkbox' name='' value='' id="sellist" onclick="checkbox1()"/>全选</th>
                <th width="150"><{t}>订单号<{/t}></th>
                <th width="150"><{t}>结算单号<{/t}></th>
                 <th ><{t}>结算完成时间<{/t}></th>
                <th ><{t}>订单总金额<{/t}></th>
                <th ><{t}>抽成金额<{/t}></th>
                <th ><{t}>积分费用<{/t}></th>
                <th ><{t}>应结金额<{/t}></th>
                <th ><{t}>处理状态<{/t}></th>
                <th ><{t}>提货码<{/t}></th>
            </tr>
            <tbody>
           <{if count($return_list)>0 }>
<{foreach from=$return_list item="return_item" name=return_list}>
<tr>
    <td> 
    <{if $return_item.looked=='true'}>
        <{if $return_item.status == 'succ'}><{t}>已结算<{/t}><{else}>
        <input type='checkbox' id='check' name='bill_id[]' value='<{$return_item.bill_id}>'/>
        <{/if}>
    <{else}>
        <{if $return_item.status == 'succ'}>
        <{t}>已结算<{/t}>
        <{else}>
        <{t}>已申请<{/t}>
        <{/if}>
    <{/if}></td>
    <td class="textcenter"><{$return_item.rel_id}></td>
    <td class="textcenter"><{$return_item.bill_id}></td>
    <td class="textcenter"><{$return_item.t_payed|cdate:'FDATE_FTIME'}></td>
    <td class="textcenter"><{$return_item.total}></td>
    <td class="textcenter"><{$return_item.profit}></td>
    <td class="textcenter" ><{$return_item.score_cost}></td>
    <td class="textcenter" <{if $return_item.status == 'ready'}>style="color:red;"<{/if}>><{$return_item.cur_money}></td>
 
    <td class="textcenter">
    
        <{if $return_item.status == 'ready'}><{t}>等待结算<{/t}> 
        <{elseif $return_item.status == 'succ'}>
            <{t}>结算成功<{/t}>
        <{/if}>
    </td>
    <td class="textcenter"><{$return_item.checkcode}></td>
   
</tr>
<{/foreach}>
<{else}>
<td colspan="5"><{t}>暂无结算数据<{/t}></td>
<{/if}>
            </tbody>
<{else}><tr><td><{$msg}></td></tr><{/if}>
        </table>
        <{pagers data=$pager}>
</div>
 <{if $look!='1' }>
<div style='float:right;'>
<input type='submit' class='btn search1'  id='out' value='申请结算'/>
<{/if}>
</div>
<!-- right-->
</form>
<script>
// $('out').addEvent('click',function(e){
//     if(confirm('确定退出?'))window.location='<{link app=business ctl=site_member act=site_balance}>';
// });
function  checkbox1()
  {
  
  var collid = document.getElementById("sellist")
  var coll = document.getElementsByName("bill_id[]")
  if (collid.checked){
     for(var i = 0; i < coll.length; i++)
       coll[i].checked = true;
  }else{
     for(var i = 0; i < coll.length; i++)
       coll[i].checked = false;
  }
  }
  //     /*小图mouseenter效果*/
    window.addEvent('domready',function(){

        var cart_product_img_viewer=new Element('div',{styles:{'position':'absolute','zIndex':500,'opacity':0,'border':'1px #666 solid'}}).inject(document.body);

        var cpiv_show=function(img,event){

            if(!img)return;
            cart_product_img_viewer.empty().adopt($(img).clone().removeProperties('width','height').setStyle('border','1px #fff solid')).fade(1);

            var size = window.getSize(), scroll = window.getScroll();
            var tip = {x: cart_product_img_viewer.offsetWidth, y: cart_product_img_viewer.offsetHeight};
            var props = {x: 'left', y: 'top'};
            for (var z in props){
                var pos = event.page[z] + 10;
                if ((pos + tip[z] - scroll[z]) > size[z]) pos = event.page[z] - 10 - tip[z];
                cart_product_img_viewer.setStyle(props[z], pos);
            }

        };

        $$('.gridlist .product-list-img').each(function(i){

            new Asset.image(i.get('isrc'),{onload:function(img){
                    if(!img)return;
                    var _img=img.zoomImg(50,50);
                    if(!_img)return;
                    _img.setStyle('cursor','pointer').addEvents({
                        'mouseenter':function(e){
                            cpiv_show(_img,e);
                        },
                        'mouseleave':function(e){
                            cart_product_img_viewer.fade(0);
                        }
                    });
                    i.empty().adopt(new Element('a',{href:i.get('ghref'),target:'_blank',styles:{border:0}}).adopt(_img));
                    },onerror:function(){
                    i.empty();

            }});

        });

    });

    function change_price(order_id){
        var login = "<{link app=business ctl='site_order' act='change_price_before'}>";
        quickPassport(login, '<{t}>修改价格<{/t}>',order_id);
    }

    function extend_confirm(order_id){
        var login = "<{link app=business ctl='site_order' act='extend_confirm_before'}>";
        quickPassport(login, '<{t}>延长收货时间<{/t}>',order_id);
    }

    function quickPassport(url, title,order_id){
    new Ex_Dialog(url, {
        title: title,
        width: 500,
        height: 250,
        modal: true,
        onLoad:function(){
            //this.content.getElement('iframe').set('scrolling','no');
        },
        asyncOptions: {
            data: 'order_id='+order_id
            
        }
    });
}
//add by hzy --start
$('btnsearch').addEvent('click',function(){
               go_url();
});

function go_url(){
    
        $('btnsearch').disabled = true;
        set_value();

}

 $('ot').addEvent('change',function(){
    set_value();
 });

function tosearch(a){
    var form=$('frm');
    var args=a.getAttribute('args');
    // var search_type=a.getAttribute('search_type');
    
    // var search_order_id = $('search_order_id').value.trim();
    // var search_goods_name = $('search_goods_name').value.trim();
    // var search_goods_bn = $('search_goods_bn').value.trim();
    // if(!search_order_id){
    //     search_order_id = '';
    // }

    // if(!search_goods_name){
    //     search_goods_name = '';
    // }

    // if(!search_goods_bn){
    //     search_goods_bn = '';
    // }

    // var p1 =  $('ot').value;
    var url="<{link app=business ctl=site_member act=site_balance arg0='"+args+"'}>";
    form.action=url;
    form.submit();

}

function set_value(){
            var form=$('frm');
            var type=form.getElement('input[name=type]').value;
            var search_order_id = $('search_order_id').value.trim();
            var search_goods_name = $('search_goods_name').value.trim();
            var search_goods_bn = $('search_goods_bn').value.trim();
            if(!search_order_id){
                search_order_id = '';
            }

            if(!search_goods_name){
                search_goods_name = '';
            }

            if(!search_goods_bn){
                search_goods_bn = '';
            }
            var p1 =  $('ot').value;
            var url="<{link app=business ctl=site_member act=seller_order arg0='"+type+"' arg1='"+search_order_id+"' arg2='"+search_goods_name+"' arg3='"+search_goods_bn+"' arg4='"+p1+"'}>";
            form.action=url;
            form.submit();
    
}
//--end

function cancel(order_id){
     Ex_Dialog.confirm('<{t}>确定要取消该订单吗？<{/t}>', function(e){
        if(!e) return;
        new Request.JSON({
            url:"<{link app=business ctl='site_order' act='docancel'}>",
            data:'order_id='+order_id,
            method:'POST',
            onSuccess:function(rs){
            
              Ex_Dialog.alert(rs);
            
              window.location.reload();
            }
          }).send();
    });

}
</script>
